new Vue({
	el: '#app',
	data: {
		uid: '',
		mobile: '',
		code: '',
		password: '',
		password_confirmation: '',
		api_token: ''
	},
	mounted: function() {
		this.init();
	},
	methods: {
		init: function() {

		},
		//关闭当前页
		close: function() {
			api.closeFrame();
		},
		jumpLogin: function() {
			api.closeFrame();
		},
		//发送短信验证码
		sendMsg: function() {
			var self = this;
			var data = {
				mobile: self.mobile,
			};
			$.post(base + config.user_register_code, data, function(msg) {
				console.log(msg);
				if(msg.error == 0) {
					api.toast({
						msg: "发送成功",
						duration: 2000,
						location: 'middle'
					});
				} else {
					api.toast({
						msg: msg.error_msg,
						duration: 2000,
						location: 'middle'
					});
				}
			}, 'json');
		},
		//注册
		register: function() {
			var self = this;
			var data = {
				mobile: self.mobile,
				code: self.code,
				password: self.password,
				password_confirmation: self.password_confirmation
			};
			$.post(base + config.guest_register, data, function(msg) {
				if(msg.error == 0) {
					$api.setStorage('uid', msg.uid);
					$api.setStorage('api_token', msg.api_token);
					self.tel = "";
					self.password = "";
					self.password_confirmation = "";
					self.code = "";
					api.toast({
						msg: msg.msg,
						duration: 1000,
						location: 'middle'
					});
					setTimeout(self.jumpLogin, 1000);
					
				} else {
					console.log(msg.msg);
					api.toast({
						msg: msg.msg,
						duration: 2000,
						location: 'middle'
					});
				}
			}, 'json');
		}
	}
})